package com.ejuornal.bean;

import java.io.Serializable;
import java.util.List;
/**    
 * 项目名称：ejuornal    
 * 类名称：Page    
 * 类描述： 分页的实体类，提供分页的实体的各种属性
 * 创建人：陈晨    
 * 创建时间：Jan 20, 2013 8:21:59 AM    
 * 修改人：陈晨    
 * 修改时间：Jan 20, 2013 8:21:59 AM    
 * 修改备注：    
 * @version     
 */
public class Page<T> implements Serializable{
   
	private static final long serialVersionUID = -5745487768111322776L;
	private List<T> records;     //当前页的记录信息 
    private int pageSize = 10;   //每页的记录数，默认为10
    private int totalRecords;    //总的记录数
    private int totalPage = 1;   //总的页数。默认值为1
    private int currentPage = 1; //当前页数，默认值为1
    private int currentRecord;   //当前记录数
    private String url;          //当前链接的url地址
    private String orderBy;     //排序
    
    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
        
    }

    public int getTotalPage() {
        return totalPage;
    }
    
    public void setTotalPage(int totalRecords) {
        int total = totalRecords / pageSize;
        int e = totalRecords % pageSize;
        if(e != 0) {
            this.totalPage = total + 1;
        } else {
            this.totalPage = total;
        }
        
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        if(currentPage < 1) {
            currentPage = 1;
        }
        this.currentPage = currentPage;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }
    
    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }
    
    public int getCurrentRecord() {
        return currentRecord;
    }

    public void setCurrentRecord(int currentRecord) {
        if(currentRecord < 1) {
            currentRecord = 1;
        }
        this.currentRecord = currentRecord;
    }
}
